<?php

/*

  Treasure	$4	
  
 Worth $1.
  While this is in play, Action cards cost $2 less, but not less than $0.

 */

class Quarry extends Card implements iTreasure, iKingdom, iInfluence, iProsperity {

    public function __construct() {
        parent::__construct("Quarry", 4);
        $this->value = new Price(1);
        $this->undoPlay = true;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Worth $1",
            "While this is in play, Action cards cost $2 less, but not less than $0.");
    }
    
    public function autoPlayNum(Game $game) {
        return -1;
    }
    
    public function play(Game $game, $isRealCard) {
        $game->pushCardToInfluence($this);
        $this->influence($game);
    }


    public function influence(Game $game) {

        $names = $game->getPlayersNames();
        foreach ($names as $name) {
            $cards = $game->getAllCards($name);
            foreach ($cards as $card) {
                if ($card instanceof iAction) {
                    $price = $card->getPrice($game);
                    $new_price = $price->add(-1);
                    $card->setPrice($new_price);
                }
            }
        }

        $actions = $game->getBoardActionCardsByPrice();
        foreach ($actions as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-2);
            $card->setPrice($new_price);
        }
    }

}

?>